<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$('form').submit(function(){
		var product_data = encodeURIComponent($('#product_data').val());
		var warehouse_id = $('#warehouse').val();
		var submit = true;
		if (!warehouse_id)
		{
			alert("仓库不能为空！");
			return false;
		}
		if (!product_data)
		{
			alert("请填写对比产品数据 ！");
			return false;
		}
	});
})
</script>

<form method="post" action="<?=url('Storage::Product/StockCompare')?>">
<table class="form_table">
	<tr>
		<th>仓库</th>
		<td>
			<select name="warehouse_id" id="warehouse">
				<option value="">请选择···</option>
				<?foreach ($warehouse as $w):?>
				<option value="<?=$w['id']?>" <?if(isset($_POST['warehouse_id']) && $_POST['warehouse_id']==$w['id'])echo "selected='selected'"?>><?=$w['name']?></option>
				<?endforeach;?>
			</select><span class="red">*</span>
		</td>
	</tr>
	<tr>
		<td colspan="4">说明：产品sku和实际库存用逗号（半角英文逗号 例：000001,1） 为一条记录，每条记录用回车分开</td>
	</tr>
	<tr>
		<th>产品</th>
		<td colspan="3"><textarea cols="50" rows="20" name="product_data" id="product_data"><?if(isset($_POST['product_data']))echo $_POST['product_data']?></textarea></td>
		<td id="wrong_product"></td>
	</tr>
	<tr>
		<td></td>
		<td colspan="3">
		<input type="hidden" name="is_search" value="1" /> 
		<input type="submit" class="button" value="库存对比" />
		<span class="red">*注意对比产品所在的仓库*</span>
		</td>
	</tr>
</table>
</form>
<?if (isset($message)):?>
<div>库存对比结果:</div>
<table width="100%" class="list_table">
<tr>
	<th width="50">SKU</th>
	<th width="180">提示信息</th>
	<th width="50">填写数量</th>
	<th width="50">实际库存</th>
	<th width="50">差额</th>
</tr>
<?foreach ($message as $k => $m): ?>
<tr class="tr">
	<td><?=$k?></td>
	<td align="left"><?=$m['message']?></td>
	<td><?=$m['quantity']?></td>
	<td><?=$m['actual_quantity']?></td>
	<td><?=$m['balance']?></td>
</tr>
<?endforeach; ?>
</table>
<?endif;?>
<?php $this->_endblock();?>